<template>
    <div>
        <h2>排房添加</h2>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">已排</td>
                    <td>
                        <input type="text" v-model="queryInfo3.yiPai" />
                    </td>
                </tr>
                <tr>
                    <td align="right">未排</td>
                    <td>
                        <input type="text" v-model="queryInfo3.weiPai" />
                    </td>
                </tr>
                <tr>
                    <td align="right">选择房型</td>
                    <td>
                        <select v-model="queryInfo3.paiRoomTypeId">
                            <option value="">请选择</option>
                            <option v-for="item in data.list" :value="item.id" :key="item.id">{{item.roomTypeName}}</option>
                        </select>
                    </td>
                </tr>
               
                <tr>
                    <td align="right">选择房号</td>
                    <td>
                        <select v-model="queryInfo3.roomNumberId">
                            <option value="">请选择</option>
                            <option v-for="item in data2.list" :value="item.id" :key="item.id">{{item.numberName}}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td align="right">状态</td>
                    <td>
                        
                        <input type="radio" name="state" :value="1" v-model="queryInfo3.state" />上架
                        <input type="radio" name="state" :value="0"  v-model="queryInfo3.state"/>下架
                       
                    </td>
                </tr>
               
                <tr>
                    <td align="right"></td>
                    <td>
                        <input type="button" @click="ok" value="添加房号" class="btn btn-primary" />
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,reactive,onMounted} from 'vue'
import { useRoute,useRouter } from 'vue-router';
import axios from 'axios';
let route=useRoute();
let router=useRouter();
let queryInfo3=reactive({
    
  yiPai: "",
  weiPai: "",
  paiRoomTypeId: "",
  roomNumberId: "",
  state: 1,
})
//房型展示
onMounted(()=>{
    GetRoomTypeList();
    GetRoomNumberList();
})
//获取房型
let data:any=reactive({
    list:[],
    totalCount:0,
    totalPage:0
})
let queryInfo1=reactive({
    Pageindex:1,
    PageSize:10,
    roomTypeName:'',
    max:'',
    min:''
})
//获取房型列表
const GetRoomTypeList=()=>{
    axios({
        url:'/api/RoomType/GetRoomTypesList',
        method:'get',
        params:queryInfo1
            
        
    })
    .then((res)=>{
        console.log(res);
        data.list=res.data.list;
        data.totalCount=res.data.totalCount;
        data.totalPage=res.data.totalPage;
    })
}
//获取房号
let data2:any=reactive({
    list:[],
    totalCount:0,
    totalPage:0
})

//房号
let queryInfo2=reactive({
    Pageindex:1,
    PageSize:10,
    numberName:'',
    createtime:'',
    
})
//获取房号列表
const GetRoomNumberList=()=>{
    axios({
        url:'/api/RoomNumber/GetRoomNumberList',
        method:'get',
        params:queryInfo2
            
        
    })
    .then((res)=>{
        console.log(res);
        data2.list=res.data.list;
        data2.totalCount=res.data.totalCount;
        data2.totalPage=res.data.totalPage;
    })
}
const ok=()=>{
    axios({
        url:'/api/PaiRoom/PaiRoomAdd',
        method:'post',
        data:queryInfo3
        
    })
    .then((res)=>{
        console.log(res);
        if(res.data==1){
            alert('添加成功');
            
        }
        

        else{
            alert('添加失败');
        }
        
    })
}
</script>

<style scoped>

</style>